package com.koko.service.Impl;

import com.koko.mapper.OrderGameMapper;
import com.koko.order.entity.OrderGame;
import com.koko.order.vo.UserAddGameByOrderVO;
import com.koko.service.OrderGameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class OrderGameServiceImpl implements OrderGameService {
    @Autowired
    private OrderGameMapper orderGameMapper;


    /**
     * 获取游戏id列表
     * @param orderId
     * @return
     */
    @Override
    public List<UserAddGameByOrderVO> getGameIdsByOrderId(Long orderId) {
        List<OrderGame> orderGameList = orderGameMapper.getOrderGameListByOrderId(orderId);
        List<UserAddGameByOrderVO> list = orderGameList.stream().map((item) -> {
            UserAddGameByOrderVO userAddGameByOrder = UserAddGameByOrderVO.builder()
                    .gameId(item.getGameId())
                    .userId(item.getReceiveId())
                    .build();
            return userAddGameByOrder;
        }).collect(Collectors.toList());
        return list;
    }
}
